package org.extframework.ld.content.model;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.extframework.ld.sort.XmlMenuSort;

/**
 * @author : Dong.Li
 * @created : 2013-1-17
 * @version : 1.0
 * @description :
 */
public class XmlMenuNode {
	private String id = "$NONE-IS-MENU$";
	private String text;
	private boolean leaf = true;
	private String pageId;
	private String iconCls;
	private int sort = 0;
	public int getSort() {
		return sort;
	}

	public String getIconCls() {
		return iconCls;
	}

	public void setIconCls(String iconCls) {
		this.iconCls = iconCls;
	}

	public void setSort(int sore) {
		this.sort = sore;
	}

	private List<XmlMenuNode> chiledMenuNodes;
	private XmlMenuNode parentMenuNode;

	public List<XmlMenuNode> getChiledMenuNodes() {
		if(this.chiledMenuNodes!=null)
			Collections.sort(this.chiledMenuNodes, new XmlMenuSort());
		return this.chiledMenuNodes;
	}

	public void setChiledMenuNodes(List<XmlMenuNode> chiledMenuNodes) {
		this.chiledMenuNodes = chiledMenuNodes;
	}

	public void addChiled(XmlMenuNode node) {
		if (this.chiledMenuNodes == null) {
			this.chiledMenuNodes = new ArrayList<XmlMenuNode>();
		}
		this.chiledMenuNodes.add(node);
	}

	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getText() {
		return this.text;
	}

	public void setText(String title) {
		this.text = title;
	}

	public String getPageId() {
		return this.pageId;
	}

	public void setPageId(String pageId) {
		this.pageId = pageId;
	}

	public XmlMenuNode getParentMenuNode() {
		return this.parentMenuNode;
	}

	public void setParentMenuNode(XmlMenuNode parentMenuNode) {
		this.parentMenuNode = parentMenuNode;
	}

	public boolean isLeaf() {
		return this.leaf;
	}

	public void setLeaf(boolean leaf) {
		this.leaf = leaf;
	}
}
